package HomeWork;

import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;

public class Demo05 {
    public static void main(String[] args) {

        try(FileWriter fw=new FileWriter("student.txt")) {
            List<Student> list=new ArrayList<>();
            list.add(new Student("张三","男","20","88"));
            list.add(new Student("李四","女","19","99"));
            for(Student student:list){
                fw.write(student.getName()+","+student.getSex()+","+student.getAge()+","+student.getScore()+System.lineSeparator());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
class Student{
    private String name;
    private String sex;
    private String age;
    private String score;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getScore() {
        return score;
    }

    public void setScore(String score) {
        this.score = score;
    }

    public Student() {
    }

    public Student(String name, String sex, String age, String score) {
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.score = score;
    }
}
